using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Weblications.Sango.Constant;
using System.Xml.Serialization;

namespace Pixysoft.Weblications.Sango.Battle
{

    class BattleHistory
    {
        private int battleResult = BattleResultCollection.UNKNOWN;

        List<BattleActionHistory> actions = new List<BattleActionHistory>();

        public BattleHistory()
        {
        }

        public List<BattleActionHistory> getActions()
        {
            return actions;
        }

        public BattleActionHistory createAction(Battler attacker, int actionTypeCode)
        {
            BattleActionHistory action = new BattleActionHistory();
            action.setAttacker(attacker.createHistory());
            action.ActionTypeCode = actionTypeCode;
            this.actions.Add(action);
            return action;
        }

        [XmlAttribute("result")]
        public int BattleResult
        {
            get { return battleResult; }
            set { battleResult = value; }
        }

        public List<BattleActionHistory> Actions
        {
            get { return actions; }
            set { actions = value; }
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            foreach (BattleActionHistory action in actions)
            {
                builder.Append(action.ToString());
            }

            builder.Append("RESULT:" + BattleResultCollection.getComment(this.battleResult));

            return builder.ToString();
        }

    }
}